home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_362 / puzz / source / message.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  901b  |  60 lines

  1. /*    Send messages to user either in Workbench or CLI.
  2.     Martin J. Round.    15-Oct-1989
  3.     Many thanks to Ali T. Ozer for his IFF2PCS program which this
  4.     routine is based on.
  5. */
  6.  
  7. extern int runningfromcli;
  8.  
  9. extern BPTR _Backstdout;
  10.  
  11. void print(char *s)
  12.     {
  13.     if (_Backstdout)
  14.         Write(_Backstdout, s, strlen(s));
  15.     }
  16.  
  17. int Min (int a, int b)
  18.     {
  19.     return ((a > b) ? b : a);
  20.     }
  21.  
  22.  
  23. int Max (int a, int b)
  24.     {
  25.     return ((a > b) ? a : b);
  26.     }
  27.  
  28. void message (UBYTE *m)
  29.     {
  30.     static struct IntuiText negtxt  =
  31.         {0,1,COMPLEMENT,4,4,NULL,(UBYTE *)" O.K.",NULL};
  32.     static struct IntuiText bodytxt =
  33.         {0,1,COMPLEMENT,10,6,NULL,NULL,NULL};
  34.  
  35.     if (m) 
  36.         {
  37.         if (runningfromcli)
  38.             {
  39.             print (m);
  40.             print ("\n");
  41.             }
  42.         else
  43.             {
  44.             bodytxt.IText = m;
  45.             WBenchToFront ();
  46.             AutoRequest 
  47.                 (
  48.                 NULL,
  49.                 &bodytxt,
  50.                 NULL,
  51.                 &negtxt,
  52.                 0L,
  53.                 0L,
  54.                 (long)(Max(Min(strlen(m)*10+50,625),200)),
  55.                 54L
  56.                 );
  57.             }
  58.         }
  59.     }
  60.